<?php

/**
 * 求职信
 *
 * @author 耿鸿飞 <15911185633>
 */
class Resume_Klez extends Model
{
    protected $tbl = 'resume_klez';
    /**
     * 添加一个新的求职信
     * @param type $uid
     * @param type $title
     * @param type $desc
     * @return Int
     */
    public function addKlez($uid,$title,$desc){
        $data = array(
            "Fuid" => $uid,
            'Ftitle' => $title,
            'Fdesc' => $desc
         );
        return $this->insert($data);
    }
    /**
     * 删除一条求职信
     * @param type $fid
     * @return type
     */
    public function delKlez($fid){
        $data = array('Fstatus' => 'Del');
        return $this->update($data, sprintf("Fid=%d",$fid));
    }
    /**
     * 编辑推荐信
     * @param type $title
     * @param type $desc
     * @param type $fid
     * @return type
     */
    public function editKlez($title,$desc,$fid){
        $data = array(
            'Ftitle' => $title,
            'Fdesc' => $desc
         );
        return $this->update($data,sprintf("Fid=%d",$fid));
    }
    /**
     * 获取推荐信
     * @param type $fid
     * @return type
     */
    public function getKlez($fid){
        return $this->getRow(sprintf("SELECT * FROM %s WHERE Fid=%d",  $this->tbl,$fid));
    }
    /**
     * 获取用户的推荐信列表
     * @param type $uid
     * @return Array
     */
    public function getKlezList($uid){
        $rs = array();
        $sql = sprintf("SELECT Ftitle,Fid FROM %s WHERE Fuid=%d ORDER BY Ftime DESC",  $this->tbl,$uid);
        $list = $this->getResults($sql);
        if($list){
            foreach($list AS $val){
                $rs[$val['Fid']] = $val['Ftitle'];
            }
        }
        return $rs;
    }
    
}

?>
